//
//  AccountDetailTableViewCell.m
//  WideHelp
//
//  Created by ENERGY on 2018/8/9.
//  Copyright © 2018年 ENERGY. All rights reserved.
//

#import "AccountDetailTableViewCell.h"

@interface AccountDetailTableViewCell()
@property (nonatomic, strong)UILabel * detailLab;
@property (nonatomic, strong)UILabel * timeLab;
@property (nonatomic, strong)UILabel * moneyLab;
@property (nonatomic, strong)UIView * lineView;
@property (nonatomic, strong)NSString * user_id;
@property (nonatomic, strong)NSString * detail_id;
@end

@implementation AccountDetailTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = [UIColor whiteColor];
        __weak typeof (self)weakSelf = self;
        [self.contentView addSubview:self.detailLab];
        [self.contentView addSubview:self.timeLab];
        [self.contentView addSubview:self.moneyLab];
        [self.contentView addSubview:self.lineView];
        [self.detailLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView.mas_left).mas_offset(16/WIDTH_6_SCALE);
            make.top.equalTo(weakSelf.contentView.mas_top).mas_offset(13/WIDTH_6_SCALE);
            make.height.mas_offset(14/WIDTH_6_SCALE);
        }];
        [self.timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.detailLab.mas_left);
            make.top.equalTo(weakSelf.detailLab.mas_bottom).mas_offset(15/WIDTH_6_SCALE);
            make.height.mas_offset(12/WIDTH_6_SCALE);
        }];
        [self.moneyLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView.mas_right).mas_offset(-58/WIDTH_6_SCALE);
            make.centerY.equalTo(weakSelf.contentView.mas_centerY);
            make.height.mas_offset(15/WIDTH_6_SCALE);
        }];
        [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(weakSelf.contentView);
            make.height.mas_offset(1/WIDTH_6_SCALE);
        }];
    }return self;
}
- (UILabel *)detailLab{
    if (!_detailLab) {
        _detailLab = [[UILabel alloc] init];
        _detailLab.font = DEF_FontSize_14;
        _detailLab.textColor = [UIColor blackColor];
        _detailLab.textAlignment = NSTextAlignmentLeft;
        _detailLab.text = @"加入";
    }return _detailLab;
}
- (UILabel *)timeLab{
    if (!_timeLab) {
        _timeLab = [[UILabel alloc] init];
        _timeLab.font = DEF_FontSize_14;
        _timeLab.textColor = getColor(@"9b9b9b");
        _timeLab.textAlignment = NSTextAlignmentLeft;
        _timeLab.text = @"2018-01-01";
    }return _timeLab;
}
- (UILabel *)moneyLab{
    if (!_moneyLab) {
        _moneyLab = [[UILabel alloc] init];
        _moneyLab.font = DEF_FontSize_14;
        _moneyLab.textColor = getColor(greenBGColor);
        _moneyLab.textAlignment = NSTextAlignmentLeft;
        _moneyLab.text = @"+30.00";
    }return _moneyLab;
}
- (UIView *)lineView{
    if (!_lineView) {
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = getColor(@"eeeeee");
    }return _lineView;
}
- (void)setModel:(NSDictionary *)model{
    _model = model;
    if ([model[@"pay_type"] isEqualToString:@"0"]) {
        self.detailLab.text = @"加入";
        self.moneyLab.text = [NSString stringWithFormat:@"+%@", model[@"pay_num"]];
    }else{
        self.detailLab.text = @"退款";
        self.moneyLab.text = [NSString stringWithFormat:@"-%@", model[@"pay_num"]];
    }
    self.timeLab.text = model[@"create_time"];
    self.detail_id = model[@"detail_id"];
    self.user_id = model[@"user_id"];
}
@end
